/*
 * TexPool.h
 *
 *  Created on: Oct 16, 2012
 *      Author: travis
 *
 *      loading textures from the directory
 *      apply texture to the opengl
 *      store filenames and IDs of textures
 */

#pragma once

#include <GL/gl.h>
#include <GL/glu.h>

#ifdef _WIN32 
#include <windows.h> 
#include "SDL.h"
#include <SDL_image.h>
#define GL_GLEXT_PROTOTYPES
#include <GL/glext.h>
#else
#include "SDL/SDL.h"
#include <SDL/SDL_image.h>
#endif

#include <iostream>
#include <dirent.h>
#include <vector>
#include <string>

struct texInfo
{
	std::string fname;
	GLuint ID;
};

class TexPool
{
public:
	// constructor need like input path to
	// directory with textures
	TexPool(std::string _texPath);
	TexPool();
	virtual ~TexPool();

	// loading immage
	// input - filename of image
	GLuint loadImage(const char* filename);

	// load whole directory of textures
	int loadDir();

	// get ID of loaded texture
	// input - filename
	// output - ID of texture in opengl memory
	GLuint getTexIdByName(std::string filename);

	// create new texture from loaded SDL Surface
	// input - SDL Surface with picture
	//		 - filename of texture
	// output - ID of texture in OGL
	// create texture and save it into pool
	GLuint createTex(SDL_Surface *img, const char* filename);

	// return all saved textures information
	std::vector<texInfo> getTextures();

	// return count of loaded textures units
	int getCount();

	void setTexPath(std::string _texPath);

private:
	std::string texPath;
	std::vector<texInfo> files;
};

